package com.fsu.database.dao;

import java.util.List;

/**
 * read-only class for information on orders
 * @author Bonazza
 *
 */
public class Order {
	
	/**
	 * the unique id of the order
	 */
	private long orderId;
	
	/**
	 * the timestamp of the order
	 */
	private long timestamp;
	
	/**
	 * the user who made the order
	 */
	User user;
	
	/**
	 * the items contained in the order
	 */
	List<Media> cart;
	
	/**
	 * Ctor
	 * @param orderId
	 * @param user
	 * @param cart
	 */
	public Order(long orderId, User user, List<Media> cart, long timestamp) {
		this.orderId = orderId;
		this.timestamp = timestamp;
		this.user = user;
		this.cart = cart;
	}
	
	/** Accessor methods */
	public long getOrderId() { return orderId; }
	public long getTimestamp() { return timestamp; }
	public User getUser() { return user; }
	public List<Media> getCart() { return cart; }
	
	public String toString() {
		String str = "order id: " + orderId + "\ntimestamp: " + timestamp + "\nuser: " + user + "\ncart: \n";
		
		for (Media m : cart) {
			if (m instanceof Book)
				str = str + (Book)m + "\n\n";
			else if (m instanceof DVD) 
				str = str + (DVD)m + "\n\n";
		}
		
		return str;
	}
}
